package com.game.springbootstart.mapper;

import com.game.springbootstart.DTO.CommentDTO;
import com.game.springbootstart.DTO.CommentsDTO;
import com.game.springbootstart.VO.CommentVO;
import com.game.springbootstart.VO.CommentsVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import com.game.springbootstart.entity.Comments;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author author
 * @since 2025-03-17
 */
@Mapper
public interface CommentsMapper extends BaseMapper<Comments> {
    List<CommentsDTO> getCommentsByGameId(CommentsVO commentsVO);

    @Delete("delete from game.comments where game_id = #{gameId} and user_id = #{userId}")
    Boolean deleteBy(CommentsVO commentsVO);

    List<CommentsDTO> getCommentsByUserId(Long userId);

    @Delete("delete from game.comments where parent_id = #{commentId}")
    void removeByParentId(Long commentId);

    @Delete("delete from game.comments where main_id = #{commentId}")
    void removeByMainId(Long commentId);

    @Select("select username from game.admin where id = #{userId}")
    String getName(Long userId);

    @Select("select name from game.games where id = #{gameId}")
    String getGame(Long gameId);


    List<CommentDTO> getComments(CommentVO commentVO, int startRow);

    @Update("update game.comments set is_liked = #{like} where id = #{commentId}")
    Boolean updateBycommentId(Long commentId, Boolean like);
}
